<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateMessagesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('messages', function (Blueprint $table) {
            $table->increments('id');

            $table->integer('from')->unsigned()->comment('消息来源方，0 表示系统消息（若 from_type 设置了类型，则以 from type 为准）')->default(0)->index();
            $table->boolean('from_type')->default(0)->comment('消息来源方类型，0 为系统消息，1 为管理员消息，2 为普通用户');
            $table->integer('to')->unsigned()->comment('消息接收方')->index();
            $table->boolean('to_type')->default(2)->comment('消息接收方类型，同 from_type')->index();

            $table->string('content')->comment('消息内容');

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('messages');
    }
}
